<template>
   <div class="my-tag">
              <input
                class="input"
                type="text"
                placeholder="输入标签"
                v-if="flag"
                v-select
                v-model="msg"
                @blur="hiddenInput"
                @keyup.enter="hiddenInput"
              />
              <div class="text" v-else @dblclick="showInput">{{ value }}</div>
            </div>
</template>
 
<script>
export default {
  
  components: {},
  props: {
    value: {
      type: [String,Number],
      required: true
    }
  },
  data() {
    return {
      flag: false,
      msg: ''
    };
  },
  
  methods: {
    showInput() {
      this.flag = true;
      this.msg = this.value
    },

    hiddenInput() {
      this.flag = false;
      this.$emit('input', this.msg)
    }
  }
};
</script>

<style scoped lang="less">
     .my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>